//
//  RootViewController.m
//  LZMProject
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 LZS. All rights reserved.
//

#import "RootViewController.h"
#import "UIImage+original.h"
#import "RootNavigationViewController.h"
#import "MineViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController


+(void)initialize
{
    
    UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    
    
    dict[NSForegroundColorAttributeName] = [UIColor redColor];
    [item setTitleTextAttributes:dict forState:UIControlStateSelected];
    
    
    UINavigationBar *bar = [UINavigationBar appearanceWhenContainedIn:self, nil];
    [bar setTitleTextAttributes:dict];
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addMyChildController];
}

-(void)addMyChildController
{
    UIViewController *news = [[UIViewController alloc]init];

    
    [self setUIViewController:news andTitle:@"新闻" andImageName:@"tabbar_icon_news_normal" andHeightImageName:@"tabbar_icon_news_highlight"];
    
    
    UIViewController *read = [[UIViewController alloc]init];
    
    [self  setUIViewController:read andTitle:@"音乐" andImageName:@"tabbar_icon_reader_normal" andHeightImageName:@"tabbar_icon_reader_highlight"];
    
    
    
    UIViewController *listen = [[UIViewController alloc]init];
    
    [ self  setUIViewController:listen andTitle:@"视听" andImageName:@"tabbar_icon_media_normal" andHeightImageName:@"tabbar_icon_media_highlight"];
    
    
    MineViewController *me = [[MineViewController alloc]init];
    
    [ self  setUIViewController:me andTitle:@"我的" andImageName:@"tabbar_icon_media_normal" andHeightImageName:@"tabbar_icon_media_highlight"];
    

    
    
    

}

-(void)setUIViewController:(UIViewController*)current andTitle:(NSString*)title andImageName:(NSString *)imageName  andHeightImageName:(NSString *)heightImageName
{
    
    current.tabBarItem.title = title;
    current.tabBarItem.image = [UIImage getoraiginalImageWithName:imageName];
    
    current.tabBarItem.selectedImage = [UIImage getoraiginalImageWithName:heightImageName];
    RootNavigationViewController *navi = [[RootNavigationViewController alloc]initWithRootViewController:current];
    
    [self addChildViewController:navi];
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
